/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package app.ernesto.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ernesto
 */
@Entity
@Table(name = "PLANES", catalog = "", schema = "OWN_PROYECTO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Planes.findAll", query = "SELECT p FROM Planes p"),
    @NamedQuery(name = "Planes.findByCodPlan", query = "SELECT p FROM Planes p WHERE p.codPlan = :codPlan"),
    @NamedQuery(name = "Planes.findByNombre", query = "SELECT p FROM Planes p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Planes.findByEntidadFinanciera", query = "SELECT p FROM Planes p WHERE p.entidadFinanciera = :entidadFinanciera")})
public class Planes implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "COD_PLAN", nullable = false, precision = 22)
    private BigDecimal codPlan;
    @Size(max = 100)
    @Column(name = "NOMBRE", length = 100)
    private String nombre;
    @Size(max = 100)
    @Column(name = "ENTIDAD_FINANCIERA", length = 100)
    private String entidadFinanciera;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codPlan", fetch = FetchType.LAZY)
    private List<Proyecto> proyectoList;

    public Planes() {
    }

    public Planes(BigDecimal codPlan) {
        this.codPlan = codPlan;
    }

    public BigDecimal getCodPlan() {
        return codPlan;
    }

    public void setCodPlan(BigDecimal codPlan) {
        this.codPlan = codPlan;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getEntidadFinanciera() {
        return entidadFinanciera;
    }

    public void setEntidadFinanciera(String entidadFinanciera) {
        this.entidadFinanciera = entidadFinanciera;
    }

    @XmlTransient
    public List<Proyecto> getProyectoList() {
        return proyectoList;
    }

    public void setProyectoList(List<Proyecto> proyectoList) {
        this.proyectoList = proyectoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codPlan != null ? codPlan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Planes)) {
            return false;
        }
        Planes other = (Planes) object;
        if ((this.codPlan == null && other.codPlan != null) || (this.codPlan != null && !this.codPlan.equals(other.codPlan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.ernesto.modelo.Planes[ codPlan=" + codPlan + " ]";
    }
    
}
